package com.yb.util.framework;

import java.util.Vector;

import com.yb.util.comm.Contants;

public class UserList {
	private static UserList manager = new UserList();
	private Vector<OnLineCustomers> vector = null;

	public UserList() {
		this.vector = new Vector<OnLineCustomers>();
	}

	public static UserList getInstance() {
		return manager;
	}

	public boolean addManager(OnLineCustomers vo) {
		if (vo != null) {
			this.vector.add(vo);
			return true;
		} else {
			return false;
		}
	}

	public Vector<OnLineCustomers> getList() {
		return vector;
	}

	public String removeManager(String id) {
		for (int i = 0; i < vector.size(); i++) {
			OnLineCustomers vo = (OnLineCustomers) vector.elementAt(i);
			String idd = vo.getSessionId();
//			System.out.println(vo.getIp()+"下线");
			if (id.equals(idd)) {
				vector.removeElementAt(i);
			}
		}
		return id;
	}
	
	public int getUserSize(){
		return vector.size()+Contants.baseOnlineUsers;
	}
}
